<template>
  <page-header-wrapper :title="false">
    <a-card>
      <div class="table-page-search-wrapper">
        <a-form layout="inline">
          <a-row :gutter="48">
            <a-col :md="6" :sm="24">
              <a-form-item label="筛选">
                <a-input :value="value" placeholder="请输入" />
              </a-form-item>
            </a-col>
            <a-col :md="(!advanced && 8) || 24" :sm="24">
              <span
                class="table-page-search-submitButtons"
                :style="(advanced && { float: 'right', overflow: 'hidden' }) || {}"
              >
                <a-button type="primary" :loading="loading" @click="handleSearch(queryParam)">查询</a-button>
                <a-button style="margin-left: 8px" @click="() => (queryParam = {})">重置</a-button>
                <!-- <a @click="toggleAdvanced" style="margin-left: 8px">
                    {{ advanced ? '收起' : '展开' }}
                    <a-icon :type="advanced ? 'up' : 'down'"/>
                  </a> -->
              </span>
            </a-col>
          </a-row>
        </a-form>
      </div>
      <a-table
        ref="table"
        size="default"
        rowKey="key"
        :loading="loading"
        :columns="columns"
        :data-source="loadData"
        :pagination="pagination"
        @change="handleTableChange"
      >
        <span slot="serial" slot-scope="text, record, index">
          {{ index + 1 }}
        </span>
        <span slot="action" slot-scope="text, record">
          <template>
            <a-tag color="#428bca" @click="handleEdit(record)">进入</a-tag>
          </template>
        </span>
      </a-table>
    </a-card>
  </page-header-wrapper>
</template>
  
  <script>
import { getStoreListUsingPOST } from '@/api/api/mendianguanli.ts'
export default {
  name: 'FinanceAdvance',
  components: {},
  data() {
    return {
      mdl: null,
      visible: false,
      value: '',
      loading: false,
      confirmLoading: false,
      // 高级搜索 展开/关闭
      advanced: false,
      // 查询参数
      queryParam: {
        pageNo: 1,
        pageSize: 10,
        queryCondition: '',
        status: '',
      },
      pagination: {},
      // 表头
      columns: [
        {
          title: '会员姓名',
          dataIndex: 'name',
        },
        {
          title: '会员电话',
          dataIndex: 'phone',
        },
        {
          title: '金额',
          dataIndex: 'price',
        },
        {
          title: '操作',
          dataIndex: 'action',
          width: '150px',
          scopedSlots: { customRender: 'action' },
        },
      ],
      // 加载数据方法 必须为 Promise 对象
      loadData: [
        { id: '1697776726648680449', name: '测试会员-001', phone:'13155829112',price: -50 },
        { id: '1699003856925491201', name: '测试会员', phone:'13155828718', price: 10 },
        { id: '1702156110079721474	', name: '小明', phone:'12345678912', price: 200 },
        { id: '1702217638493552641', name: '陈先生',  phone:'13306929955',price: 0 },
      ],
      optionAlertShow: false,
    }
  },
  created() {
    this.handleSearch(this.queryParam)
  },
  methods: {
    handleSearch(params) {
      this.loading = true
      setTimeout(() => {
        this.loading = false
      }, 1000)
      // getStoreListUsingPOST(params).then((res) => {
      //   this.loadData = res.data.list
      //   this.queryParam.pageNo = this.pagination.current
      //   this.pagination = { ...this.pagination, total: Number(res.data.total) }
      //   this.loading = false
      // })
      // .catch((error) => {
      //   this.loading = false
      //   this.$message.error(((error.response || {}).data || {}).msg || '请求出现错误')
      // })
    },
    handleTableChange(pagination, filters, sorter) {
      const pager = { ...this.pagination }
      pager.current = pagination.current
 pager.pageSize = pagination.pageSize
      this.pagination = pager
      this.handleSearch({
        sortField: sorter.field,
        sortOrder: sorter.order,
        ...filters,
        pageNo: pagination.current,
        pageSize: pagination.pageSize,
        queryCondition: this.queryParam.queryCondition,
        status: this.queryParam.status,
        date: this.queryParam.date,
      })
    },
    handleEdit(record) {
      this.$router.push({ path: `/member/list/detail/${record.id}` })
    },
  },
}
</script>